Skip to content

Feat/hasclaim cache - #147

Open
oscar24357 wants to merge 9 commits into
ToluLabs:mainfrom
oscar24357:feat/hasclaim-cache
Open

Feat/hasclaim cache#147
oscar24357 wants to merge 9 commits into
ToluLabs:mainfrom
oscar24357:feat/hasclaim-cache

Conversation

@oscar24357

@oscar24357 oscar24357 commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

closes #129

Greptile Summary

This PR adds an opt-in in-memory cache to StellarCred.hasClaim, a new invalidate API, full i18n support across all frontend pages via next-intl, a LangSwitcher component, and a tag-driven release workflow. The SDK cache itself is well-designed and the test coverage is thorough, but the implementation was merged with numerous incomplete edits throughout the codebase.

  • SDK (index.ts): invalidate's closing brace is missing so the old configure is parsed as a nested function inside it; two StellarCred namespace exports exist on back-to-back lines; trustedIssuers is silently dropped in the cached code path.
  • Frontend pages (holder, issuer, verify, apps, apps/[id], layout, SiteNav): Every file has at least one duplicate import, unclosed JSX expression, or duplicate JSX prop — all of which are TypeScript compile errors that prevent the app from building.
  • verify/page.tsx: Newly added returnUrlIsValid / returnLabel computation accesses window.location.origin directly in the component body without an SSR guard, crashing server-side rendering of the /verify route.

Confidence Score: 1/5

Not safe to merge — the frontend does not compile and the SDK does not compile.

Every changed frontend page and the SDK itself contain TypeScript compile errors (duplicate imports, unclosed JSX, duplicate identifier declarations). The app cannot be built or deployed in this state. Additionally, the /verify page will crash server-side rendering on every request due to an unguarded window access at render time.

Files Needing Attention: All changed frontend pages need merge-artifact cleanup; frontend/packages/sdk/src/index.ts needs its invalidate function closed and the two duplicate StellarCred exports consolidated; frontend/app/verify/page.tsx needs the window.location.origin render-time access guarded.

Important Files Changed

Filename Overview
frontend/packages/sdk/src/index.ts Core SDK change adding opt-in hasClaim caching, invalidate, and ConfigureOptions interface — but the refactor left the invalidate function body unclosed (old configure is nested inside it), two StellarCred export declarations, trustedIssuers silently dropped from cached path, and dead code after return result.
frontend/packages/sdk/src/index.test.ts New test suite covering cache hit/miss, TTL expiry, per-wallet/type invalidation, and configure options — good coverage of the intended behaviour, but tests cannot run because the SDK itself does not compile.
frontend/app/holder/page.tsx i18n strings wired in and new QR-transfer button added, but the new import line duplicates useEffect/useRef/useState (already imported via the existing Suspense line), and two JSX elements have duplicate title/subtitle props — both are TypeScript compile errors.
frontend/app/verify/page.tsx i18n wired in and redirectAfterIssue partially refactored, but the function body has two unclosed nested if blocks, a separate unclosed JSX expression, and a new render-time window.location.origin access without an SSR guard that crashes server-side rendering of the page.
frontend/app/layout.tsx Adds LocaleProvider wrapping the app, but the new provider tree was inserted without removing the original ToastProvider/WalletProvider subtree, rendering the nav, main, and footer twice and omitting NetworkBanner and toasts from the new tree.
.github/workflows/release.yml New tag-triggered release workflow that generates a CHANGELOG, creates a GitHub Release, and publishes to npm — overall sound, but git push origin HEAD:main from a detached-HEAD tag checkout will fail when main has branch protection, leaving releases in a half-finished state.
frontend/components/SiteNav.tsx Adds LangSwitcher to the nav, but IconBook2 and IconCode are imported twice (new partial import on line 7 and the original full import on line 9), causing TypeScript to reject the file.
.github/workflows/ci.yml Adds a commitlint job to the CI pipeline that lints PR commit messages against conventional commits — straightforward and correct.

Sequence Diagram

sequenceDiagram
    participant App as Calling App
    participant SDK as @stellarcred/sdk
    participant Cache as In-Memory Cache
    participant RPC as Stellar RPC

    App->>SDK: hasClaim(wallet, claimType, opts)
    SDK->>SDK: buildCacheKey(wallet, claimType, minThreshold)
    alt "cacheEnabled && cache hit"
        SDK->>Cache: get(cacheKey)
        Cache-->>SDK: CacheEntry (value, expiresAt)
        SDK-->>App: cached boolean (no RPC)
    else cache miss or disabled
        alt minThreshold set
            SDK->>RPC: readCheckClaim(wallet, claimType, minThreshold)
        else binary claim
            SDK->>RPC: readIsVerified(wallet, claimType)
        end
        RPC-->>SDK: result
        alt cacheEnabled
            SDK->>Cache: "set(cacheKey, {value, expiresAt})"
        end
        SDK-->>App: result
    end

    App->>SDK: invalidate(wallet?, credentialType?)
    SDK->>Cache: delete matching entries
Loading

Reviews (7): Last reviewed commit: "Merge branch 'main' into feat/hasclaim-c..." | Re-trigger Greptile

@vercel

vercel Bot commented Jul 26, 2026

Copy link
Copy Markdown

@oscar24357 is attempting to deploy a commit to the psalmuel01's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Jul 26, 2026

Copy link
Copy Markdown

@oscar24357 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Comment thread frontend/packages/sdk/src/index.ts
Comment thread frontend/app/issuer/page.tsx
Comment thread frontend/components/SiteNav.tsx
Comment thread frontend/app/verify/page.tsx
@oscar24357

Copy link
Copy Markdown
Contributor Author

hello boss, can you please assign this point to me on drips, thank you

Comment thread frontend/app/verify/page.tsx
@oscar24357

Copy link
Copy Markdown
Contributor Author

Hello maintainer, good evening. Can you please award this points to me on drips..thank you

Comment thread frontend/packages/sdk/src/index.ts
@oscar24357

Copy link
Copy Markdown
Contributor Author

can you give please give me the points to this issue

@oscar24357

Copy link
Copy Markdown
Contributor Author

hello boss, can you award this points to me on drips please, thank you

@Psalmuel01

Copy link
Copy Markdown
Collaborator

this is failing and greptile score is 1

@Psalmuel01

Psalmuel01 commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

@oscar24357 rebase and fix conflicts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SDK: caching layer for claim reads with configurable TTL

2 participants